package com.wang.service;

import com.wang.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: along
 * @Create: 2021/6/7
 * @Description:
 */
@Component
public class DeptClientServiceFactory implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public Dept queryById(Long id) {
                return new Dept()
                        .setDno(id)
                        .setDname("id==>" + id + "不存在该用户，或者信息无法找到")
                        .setDb_source("no such database in MySQL");
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
